<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class SmsController extends Controller
{
    public function send_sms(request $req,$mobile){
        $aldy=new \Myclass\Aldy\AldySdk;
        $num=str_random(4);
        //验证码写入session
        $req->session()->put('smscode', $num);
        $arr=['name'=>$req->user()->name,'val'=>'欢迎注册ddd','num'=>$num];
        //短信签名,模板id,手机号,参数(数组形式传递)
        $rs=$aldy->sendsms('用户名验证','SMS_8981143',$mobile,$arr);
        return $rs->result->success;
    }

    public function yz_sms(request $req,$code){
        if ($code==$req->session()->get('smscode')) {
            return 'OK';
        }else{
            return 'error';
        }
    }
}
